import axios from 'axios'
axios.defaults.baseURL = 'http://localhost:8888/api'

// 获取图片列表顶部分类
export const getImgcategory = () => axios.get('/getimgcategory').then(res => res.data)

// 根据分类id获取图片列表
export const getImages = (id) => axios.get(`/getimages/${id}`).then(res => res.data)

// 获取图文详情缩略图 及 商品列表详情轮播图
export const getThumimages = (id) => axios.get(`/getthumimages/${id}`).then(res => res.data)

// 获取缩略图描述
export const getImginfo = (id) => axios.get(`/getimageInfo/${id}`).then(res => res.data)
// 新闻资讯接口
// 获取新闻列表
export const getNewsList = () => axios.get('/getnewslist').then(res => res.data)
// 获取新闻详情
export const getNewsDetail = (id) => axios.get(`/getnew/${id}`).then(res => res.data)
// 获取购物车页面数据
export const getshopCarlist = (id) => axios.get(`/goods/getshopcarlist/${id}`).then(res => res.data)

// 商品详情数据获取
// export const getDetailData = (id) => axios.get(`/goods/getdesc/${id}`).then(res => res.data)

// 获取商品价格及描述
export const getCartInfo = (id) => axios.get(`/goods/getinfo/${id}`).then(res => res.data)

// 获取轮播图数据
export const getSwipeData = (id) => axios.get(`/getthumimages/${id}`).then(res => res.data)

// 获取商品列表数据
export const getListData = pageindex => axios.get(`/getgoods?pageindex=${pageindex}`).then(res => res.data)
// 评论接口
export const getCommentList = (id, pageIndex) => axios.get(`/getcomments/${id}?pageindex=${pageIndex}`).then(res => res.data)
// 发表评论
export const postComment = (id, content) => axios.post(`/postcomment/${id}`, content).then(res => res.data)

// 获取商品图文介绍
export const getDesc = (id) => axios.get(`/goods/getdesc/${id}`).then(res => res.data)
